package com.pro.controller;

import com.google.gson.Gson;
import com.pro.pojo.JsClosure;
import com.pro.pojo.JsUnseal;
import com.pro.pojo.JsonData;
import com.pro.service.JsPeopleListService;
import com.pro.service.JsPeopleUnsealingLogService;
import com.pro.utils.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName:JsPeopleUnsealingLogController
 * Package:com.pro.controller
 * Description:
 *
 * @Date:2021/12/4 17:31
 * @Author: XJR
 */
@RestController
@RequestMapping("/JsPeopleUnsealingLog")
public class JsPeopleUnsealingLogController {
    @Autowired
    private JsPeopleUnsealingLogService service;

    @Autowired
    private RedisCache redisCache;

    private Gson gson = new Gson();

    @RequestMapping("/SelectPeopleUnsealing")
    public JsonData SelectPeopleUnsealing(String account, String deptName, String unsealDate, Integer limit, Integer page){
        account = !("").equals(account) && account !=null?"%"+account+"%":"%%";
        deptName = !("").equals(deptName) && deptName !=null?"%"+deptName+"%":"%%";
        unsealDate = !("").equals(unsealDate) && unsealDate !=null?"%"+unsealDate+"%":"%%";
        List<JsUnseal> jsClosures = service.SelectPeopleUnsealing(account, deptName, unsealDate, limit, page);
        Integer integer = service.countSelectPeopleUnsealing(account, deptName, unsealDate);
        //redis缓存
        String jsPeopleUnsealingLogSelect = redisCache.getCacheObject("JsPeopleUnsealingLogSelect");
        List list = gson.fromJson(jsPeopleUnsealingLogSelect, List.class);
        Integer integer1 = redisCache.getCacheObject("JsPeopleUnsealingLogCount");
        return list!=null?JsonData.buildSuccess(list,integer1):JsonData.buildError("服务端错误");
    };
}
